//
//  SEPrescriptionListCell.swift
//  SmartEyeForDoctor
//
//  Created by QDSG on 2021/5/10.
//

import UIKit

class SEPrescriptionListCell: UITableViewCell {
    
    var changeHandler: (() -> Void)?
    
    override func setHighlighted(_ highlighted: Bool, animated: Bool) {
        super.setHighlighted(highlighted, animated: animated)
        containerView.backgroundColor = highlighted ? Asset.clickHighlight.color : Asset.white.color
    }

    func update(with viewModel: SEPrescriptionViewModel) {
        nameLabel.text = viewModel.prescriptionName
        statusLabel.text = viewModel.prescription.status.text
        statusLabel.textColor = viewModel.prescription.status.textColor
        descLabel.text = viewModel.prescription.status.desc
        descLabel.textColor = viewModel.prescription.status.descColor
        deleteButton.isHidden = viewModel.prescription.status.deleteHidden
    }
    
    @IBAction private func deleteAction() {
        changeHandler?()
    }
    
    @IBOutlet private weak var containerView: UIView! {
        didSet {
            containerView.setLayerCorners(rect: containerView.bounds, radius: 6)
            containerView.setShadow()
        }
    }
    @IBOutlet private weak var nameLabel: UILabel!
    @IBOutlet private weak var statusLabel: UILabel!
    @IBOutlet private weak var descLabel: UILabel!
    @IBOutlet private weak var deleteButton: UIButton!
}
